package com.baimifan.renovation.view;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;

import com.zhouwei.mzbanner.holder.MZViewHolder;

import org.xutils.image.ImageOptions;
import org.xutils.x;

/**
 * Created by baimifan on 2017/07/03.
 */

public class BannerViewHolder implements MZViewHolder<String> {
    private ImageView imageView;
    private ImageOptions imageOptions;
    private Float width,  height;

    public BannerViewHolder(Float width, Float height) {
        this.width = width;
        this.height = height;
        imageOptions = new ImageOptions.Builder()
                .setSize((int)(width*338), (int)(height*150))
                .setImageScaleType(ImageView.ScaleType.FIT_XY)
                .build();
    }

    @Override
    public View createView(Context context) {
        imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setPadding((int)(width*12),(int)(height*12), (int)(width*13), (int)(height*15));
        return imageView;
    }

    @Override
    public void onBind(Context context, int i, String s) {
        x.image().bind(imageView, s, imageOptions);
    }
}
